package com.example.recognize.service;

import com.example.recognize.mapper.MenuMapper;
import com.example.recognize.model.Hr;
import com.example.recognize.model.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@CacheConfig(cacheNames = "menus_cache")
public class MenuService {
    @Autowired
    MenuMapper menuMapper;



    public List<Menu> getAllMenusWithRole(){
        return menuMapper.getAllMenusWithRole();
    }

    public List<Menu> getMenusByHrId() {
        Hr principal = (Hr) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        System.out.println(principal);
        return menuMapper.getMenusByHrId(((Hr) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
    }
}
